package com.ccrfid.rmc6.pojo.huxi;

import com.vividsolutions.jts.geom.Point;

import java.util.List;
import java.util.stream.Collectors;

public class TabConfig {
    private String name;
    private Integer type;   //0-left;1-right
    private Point pos;
    private List<ConfigItem> items;

    public TabConfig() {
    }

    public TabConfig(String name, Integer type, Point pos, List<ConfigItem> items) {
        this.name = name;
        this.type = type;
        this.pos = pos;
        this.items = items;
    }

    public TabData toTabData() {
        List<DataItem> dataItems = items.stream()
                .map(configItem -> new DataItem(configItem.getName(), configItem.getCount()))
                .collect(Collectors.toList());
        Integer count = dataItems.stream().mapToInt(DataItem::getCount).sum();
        return new TabData(name, count, type, pos, dataItems);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Point getPos() {
        return pos;
    }

    public void setPos(Point pos) {
        this.pos = pos;
    }

    public List<ConfigItem> getItems() {
        return items;
    }

    public void setItems(List<ConfigItem> items) {
        this.items = items;
    }
}
